package com.webchat.chat.service.impl;

import com.webchat.chat.core.enums.SocketRoomStatus;
import com.webchat.chat.dao.RoomClientMapper;
import com.webchat.chat.model.RoomClient;
import com.webchat.chat.service.RoomClientService;
import com.webchat.chat.core.AbstractService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


/**
 * Created by admin on 2018-06-29.
 */
@Service
@Transactional
public class RoomClientServiceImpl extends AbstractService<RoomClient> implements RoomClientService {
    @Resource
    private RoomClientMapper roomClientMapper;

    @Override
    public List<RoomClient> findByCondition(RoomClient condition) {
        return roomClientMapper.selectByCondition(condition);
    }

    @Override
    public RoomClient findByRoomId(String roomId, String clientId) {
        return roomClientMapper.selectByRoomId(roomId, clientId);
    }

    @Override
    public List<RoomClient> findByRoomId(String roomId) {
        return roomClientMapper.selectRoomClientsByRoomId(roomId);
    }

    @Override
    public List<RoomClient> findByRoomId(String roomId, SocketRoomStatus status) {
        return roomClientMapper.selectRoomClientsByRoomIdAndStatus(roomId, status);
    }

    @Override
    public List<RoomClient> findByclientId(String clientId, SocketRoomStatus status) {
        return roomClientMapper.selectByClientId(clientId, status);
    }
}
